var app = new Vue({
	el:'#player',
	data:{
		query:'',
		musicList:[],
		musicUrl:'',
		imgUrl:'',
		musicComments:[],
		isPlaying:false,
		mvUrl:'',
		isShow:false
	},
	methods:{
		//音乐查询
		searchMusic:function(){
			axios.get("https://autumnfish.cn/search?keywords="+this.query).then((res)=>{
				console.log(res.data.result.songs);
				this.musicList=res.data.result.songs;
			}).catch((err)=>{
				console.log(err)
			})
		},
		//音乐播放
		playMusic:function(musicId){
			axios.get("https://autumnfish.cn/song/url?id="+musicId).then((res)=>{
				console.log(res.data.data[0].url);
				this.musicUrl=res.data.data[0].url;
			}).catch((err)=>{
				console.log(err);
			})
			//音乐封面
			axios.get("https://autumnfish.cn/song/detail?ids="+musicId).then((res)=>{
				//console.log(res.data.songs[0].al.picUrl);
				this.imgUrl=res.data.songs[0].al.picUrl;
			}).catch((err)=>{
				console.log(err);
			})
			//热门评论
			axios.get("https://autumnfish.cn/comment/hot?type=0&id="+musicId).then((res)=>{
				//console.log(res.data.hotComments);
				this.musicComments=res.data.hotComments;
			}).catch((err)=>{
				console.log(err);
			})
		},
		//播放时动画打开
		play:function(){
			this.isPlaying=true;
		},
		//暂停时动画暂停
		pause:function(){
			this.isPlaying=false;
		},
		//获取mv的Url
		playMv:function(mvId){
			if(mvId){
				this.isShow=true;
				axios.get("https://autumnfish.cn/mv/url?id="+mvId).then((res)=>{
					//console.log(res.data.data.url);
					this.mvUrl=res.data.data.url;
				}).catch((err)=>{
					console.log(err);
				})
			}
			
		},
		//关闭mv
		closeVideo:function(){
			this.isShow=false;
			//关闭之后,视频也不再播放了
			this.$refs.video.pause();
		}
	}
})